package com.lucifer.hawkeye.ai.api;

import com.lucifer.hawkeye.ai.common.response.RestResult;
import com.lucifer.hawkeye.ai.domain.conversation.vo.ConversationVO;
import com.lucifer.hawkeye.ai.service.ConversationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lucifer
 * @date 2025/4/1 14:25
 */
@RestController
@RequestMapping("/conversation")
public class ConversationApi {

    @Resource
    private ConversationService conversationService;

    @GetMapping("/create")
    public RestResult<ConversationVO> create(
            @RequestParam(value = "conversationType") String conversationType
    ) {
        return conversationService.create(conversationType);
    }


    @PutMapping("/edit")
    public RestResult<Void> edit(
            @RequestParam(value = "conversationId") String conversationId,
            @RequestParam(value = "title") String title) {
        return conversationService.edit(conversationId, title);
    }

    @GetMapping("/list")
    public RestResult<List<ConversationVO>> list() {
        return conversationService.list();
    }

    @GetMapping("/get")
    public RestResult<ConversationVO> get(@RequestParam(value = "conversationId") String conversationId) {
        return conversationService.get(conversationId);
    }

    @DeleteMapping("/del")
    public RestResult<Void> del(@RequestParam(value = "conversationId")String conversationId) {
        return conversationService.del(conversationId);
    }

}
